Conversation
d7eb6c1 to
0b20ee3
Compare
| CompletablePromise<String> promise = Workflow.newPromise(); | ||
| QueuedCommand queuedCommand = new QueuedCommand(command, promise); | ||
| this.commandQueue.add(queuedCommand); | ||
| return queuedCommand.promise.get(); |
There was a problem hiding this comment.
@Quinn-With-Two-Ns Is there a way here to free up the update thread? e.g. could the update handler return the promise, rather than block on .get()?
There was a problem hiding this comment.
Good point, I'd be interested to know this, but haven't looked into it yet.
There was a problem hiding this comment.
Yeah we can explore alternative approaches that use less threads. Given we only allow 10 concurrent updates it wasn't prioritized, virtual threads also make this not a big deal.
| } | ||
| } | ||
|
|
||
| private ArrayList<QueuedCommand> commandQueue; |
There was a problem hiding this comment.
ArrayList works in this case, but prefer WorkflowQueue instead. It provides a more appropriate API, inspired from "Blocking Queue", but Workflow-safe (it internally use Workflow.await() to implement blocking ops).
There was a problem hiding this comment.
Thanks! Yes @Quinn-With-Two-Ns pointed that out to me also.
[Draft]